# $Id: PKGBUILD 87881 2013-04-08 12:41:31Z jconder $
# Maintainer: Jonathan Conder <jonno.conder@gmail.com>
pkgbase='packagekit'
pkgname=('packagekit' 'packagekit-qt2' 'python2-packagekit')
pkgver=0.7.6
pkgrel=9
pkgdesc="A system designed to make installation and updates of packages easier."
arch=('i686' 'x86_64')
url="http://www.packagekit.org"
license=('GPL')
makedepends=('dbus-glib' 'gobject-introspection' 'gtk-doc' 'intltool'
             'networkmanager' 'pacman'  'pm-utils' 'polkit' 'python2' 'qt4'
             'shared-mime-info' 'sqlite' 'udev')
options=('!libtool')
source=("http://www.packagekit.org/releases/PackageKit-$pkgver.tar.xz"
        'adopt.patch'
	'alpm.patch'
	'libarchive.patch')
sha256sums=('82c0a553075d49add3c4f58e6e93f7f3613938809a4b8e36f46476e86981b45d'
            'd0ee8580202a878571dddd470017731299c63e5c5120afe881bb41b9544322b8'
	    'd27c77d3c0e2932fff2916fedcae011bd283904ef7c329dd0dc05163b58d7415'
	    '0d3798c8992afdc0930aa271b3e44deb55c046ab4adee25b4ec4c33bcdd950e2')

build() {
  cd "$srcdir/PackageKit-$pkgver"

  sed -i 's@SUBDIRS = test@SUBDIRS =@' 'backends/Makefile.in'
  sed -i 's@python @python2 @' 'lib/python/packagekit/Makefile.in'
  sed -i 's@bin/python@bin/python2@' 'lib/python/packagekit/'*.py

  patch -Np1 -i "$srcdir/adopt.patch"
  patch -Np1 -i "$srcdir/alpm.patch"
  patch -Np1 -i "$srcdir/libarchive.patch"

  export PYTHON=/usr/bin/python2
  ./autogen.sh --prefix=/usr \
              --sysconfdir=/etc \
              --localstatedir=/var \
              --libexecdir=/usr/lib/PackageKit \
              --enable-strict \
              --disable-static \
              --disable-gtk-doc \
              --disable-tests \
              --disable-local \
              --disable-browser-plugin \
              --disable-gstreamer-plugin \
              --disable-gtk-module \
              --disable-command-not-found \
              --disable-cron \
              --disable-debuginfo-install \
              --enable-pm-utils \
              --disable-dummy \
              --enable-alpm \
              --with-default-backend=alpm
  make -s CFLAGS='-D_FILE_OFFSET_BITS=64 -O2 -Wno-unused-local-typedefs'
}

package_packagekit() {
  backup=('var/lib/PackageKit/transactions.db'
          'etc/PackageKit/alpm.d/pacman.conf'
          'etc/PackageKit/alpm.d/repos.list')
  depends=('dbus-glib' 'pacman>=4.1.0' 'pacman<4.2.0' 'polkit'
           'shared-mime-info' 'sqlite' 'udev')
  optdepends=('networkmanager')
  install='packagekit.install'

  cd "$srcdir/PackageKit-$pkgver"

  make DESTDIR="$pkgdir" install

  rm -rf "$pkgdir/usr/include/PackageKit/packagekit-qt"*
  rm -rf "$pkgdir/usr/lib/libpackagekit-qt"*
  rm -rf "$pkgdir/usr/lib/pkgconfig/packagekit-qt"*
  rm -rf "$pkgdir/usr/lib/cmake"

  rm -rf "$pkgdir/usr/lib/python"*
  rm -rf "$pkgdir/usr/share/PackageKit/website"

  mkdir -p "$pkgdir/usr/share/bash-completion/completions"
  mv "$pkgdir/etc/bash_completion.d/pk-completion.bash" \
     "$pkgdir/usr/share/bash-completion/completions/pkcon"
  rmdir "$pkgdir/etc/bash_completion.d"
  touch "$pkgdir/var/log/PackageKit"
}

package_packagekit-qt2() {
  depends=('packagekit' 'qt4')
  pkgdesc=('Qt bindings for PackageKit')

  cd "$srcdir/PackageKit-$pkgver/lib/packagekit-qt2"

  make DESTDIR="$pkgdir" install
}

package_python2-packagekit() {
  depends=('packagekit' 'python2')
  pkgdesc=('Python bindings for PackageKit')
  conflicts=('packagekit-python')
  replaces=('packagekit-python')

  cd "$srcdir/PackageKit-$pkgver/lib/python"

  make DESTDIR="$pkgdir" install
}
